<?php
namespace app\common\exception;
use Exception;
use think\exception\Handle;
use think\facade\Request;

class ExceptionHandle extends Handle
{
	public function render(Exception $e)
	{
		if(config('show_error_msg')){
			return parent::render($e);
		}else{
			$module = Request::instance()->module();
			if($module == 'api' || $module == 'union' || $module == 'trademark'){
				return json(['code'=>500,'msg'=> '错误代码:' . $e->getCode() . ' 错误描述:' . $e->getMessage()]);
			}
			$vars['code'] = 0;
			$vars['error'] = $e->getCode();
			$vars['msg'] = $e->getMessage();
			$vars['wait'] = 10;
			$vars['url'] = '/';
			return view(env('app_path').'home/view/message.html',$vars);
		}
	}
}